<?php

/**
 * @author Christian Monzon
 * @copyright 2011
 */

Class RegisterPackDraw
{
    //.enviando nuevos cambios.......................
    
    //agregando nueva variable 
    
    public static $instance2;
    public static $instance;
    
 
    
    function __construct()
    {
      
        
    }
    function  DrawHead($action,$name,$method,$NAME){echo "<div id='register-box'>\n";echo "<form action='$action' method='$method' name='$name'>\n";echo "<h2>$NAME</h2>\n";}
    function  DrawFoot(){
        echo "</form>";
        echo "</div>";}
    function  DrawTextBox($items)
    {
        
        ?>
               <p>
               <?php
                    foreach($items as $id => $valor)
                    {
                        echo "<label>".$valor."<input type='text' name='$id' class='general-textarea'>"."</label>";
                        
                    }
               
               ?>
               
               </p> 
            
        
        
        <?php
        
    }
    
    function DrawSelect($table,$campos,$NAME)//especificar los campos que deben de aparecer 
    {
        $query="select " ;
        foreach($campos as $campo => $valor){$query=$query.$valor.",";
        }
        $query= substr($query,0,strlen($query)-1);
         $query=$query." from ".$table;
      
        $table2=CModelo::getInstance()->getData($query);
        echo $campos[0];
        
        //var_dump($table2);
        ?>
        
        
        <label><?php echo $NAME;?>
        <select name="<?php echo $campos[0];?>" class="input_pulldown">
        <?php
        foreach($table2 as $row =>$colum)
        {
        $tabla=$colum;$select="";$i=0;
        foreach($tabla as $campo=>$valor)
        {
            //if($i>0){$select=$select."<option value=".$tabla[$campo]."> ";}
            if($i<=0){$select=$select."<option value=".$valor."> ($valor) ";}
            //$select=$select.$tabla[$campo].",";$i=$i+1;
            else{$select=$select.$tabla[$campo]." ";}
            $i=$i+1;
        }
        echo $select."</option>\n";
        //echo "<option value=".$tabla['idOfi'].">".$tabla['DirOfi']."</option>\n";    
        }
        ?>
        </select>       
        </label>
        
    
    <?php
    }
    
    
    
      
    function DrawMultipleSelect($table,$campos,$NAME)//especificar los campos que deben de aparecer 
    {
        $query="select " ;
        foreach($campos as $campo => $valor){$query=$query.$valor.",";}
        $query= substr($query,0,strlen($query)-1);
         $query=$query." from ".$table;
        
        $table2=CModelo::getInstance()->getData($query);
        
        
        //var_dump($table2);
        ?>
        
        
        <label><?php echo $NAME;?>
        <select name="multi[]" multiple="multiple" class="input_pulldown" >
        <?php
        foreach($table2 as $row =>$colum)
        {
        $tabla=$colum;$select="";$i=0;
        foreach($tabla as $campo=>$valor)
        {
            //if($i>0){$select=$select."<option value=".$tabla[$campo]."> ";}
            if($i<=0){$select=$select."<option value=".$valor."> ($valor) ";}
            //$select=$select.$tabla[$campo].",";$i=$i+1;
            else{$select=$select.$tabla[$campo]." ";}
            $i=$i+1;
        }
        echo $select."</option>\n";
        //echo "<option value=".$tabla['idOfi'].">".$tabla['DirOfi']."</option>\n";    
        }
        ?>
        </select>       
        </label>
        
    
    <?php
    }
    
    
    
    function DrawButton($nombre,$ruta,$i){
        
        echo "<td> <input type=button onClick=\"parent.location='$ruta&codigo=$i'\" value='$nombre'>  </td>";
    
    }
    
    function DrawRadioButton($items,$name)
    {
      
      echo "<p >";
      
      foreach($items as $id => $valor)
                    {
                        echo "<label>".$id."<input type='radio' class=\"input-radio\" name='$name' value='$valor'>"."</label>\n";
                        
                    }
      
      
      echo "</p>";
      
        
        
    }
    
    function HiddenValue($hidden){
        echo "<input type='hidden' name='idHidden' value='$hidden'>"; 
    }
    
    function DrawSubmmit($nombre){echo "<input class='submit_button' type='submit' name=$nombre value='$nombre'>";}
   
    public static function getInstance()
	{
		//echo "<div id=register-box>";
        if(self::$instance==null)
		  self::$instance=new RegisterPackDraw();
	//   echo "</div>";	  
		return  self::$instance;
	   
    
    }	
    
    
}

?>